package com.zbs.framework.swagger.entity.eolink;

import com.zbs.framework.swagger.entity.RequestParams;
import lombok.Data;

import java.util.List;

@Data
public class ParamInfo {
    private String paramNotNull;
    private String paramType;
    private String paramName;
    private String paramKey;
    private String paramValue;
    private String paramLimit;
    private String paramNote;
    private List<ParamInfo> childList;

    public ParamInfo(RequestParams params) {
        this.paramNotNull = params.isRequired() ? "0" : "1";
        this.paramType = params.isArray() ? "12" : getParamType(params.getDataType());
        this.paramKey = params.getName();
        this.paramName = params.getDescribe();
        this.paramValue = "";
        this.paramLimit = "";
        this.paramNote = "";

    }

    private String getParamType(String str) {
        switch (str) {
            case "java.lang.String":
                return "0";
            case "java.lang.Integer":
            case "java.lang.Long":
            case "int":
            case "long":
                return "14";
            case "java.lang.Double":
            case "double":
            case "short":
            case "java.lang.Short":
            case "java.math.BigDecimal":
                return "5";
            case "boolean":
            case "java.lang.Boolean":
                return "8";
            case "char":
            case "java.lang.Character":
                return "char";
            case "org.springframework.web.multipart.MultipartFile":
            case "java.io.File":
                return "1";
            case "java.util.Date":
            case "java.time.LocalDateTime":
                return "7";
            default:
                return "13";
        }
    }
}
